<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="button" value="中文" @click="changeLang('zh')" >
        <input type="button" value="english"  @click="changeLang('en')" >
        <hr/>
        <h1>{{uIObj[language].title}}</h1>
        <p>
            {{uIObj[language].username}}:<input type="text" v-model="username"/>
        </p>
        <p>
            {{uIObj[language].userpass}}:<input type="password" v-model="userpass"/>
        </p>
        <p>
            {{uIObj[language].userpass2}}:<input type="password" v-model="userpass2" />
        </p>
        <p>
            <input type="button" :value="uIObj[language].regButton" @click="regSave">
        </p>
    </div>
</body>

</html>
<script src="./js/vue.global.js"></script>
<script src="./js/myvant.js"></script>
<script>

    const {createApp} = Vue;
    
    let app = createApp({
        components:{},
        data(){
            return {
                username:"",
                userpass:"",
                userpass2:"",
                language:"zh",
                uIObj:{
                    "zh":{
                        title:"注册界面",
                        username:"用户名",
                        userpass:"密码",
                        userpass2:"确认密码",
                        regButton:"注册",
                        errMsgPass:"两次密码不一致"
                    },
                    "en":{
                        title:"registerPage",
                        username:"username",
                        userpass:"password",
                        userpass2:"confirmPassword",
                        regButton:"sign",
                        errMsgPass:"The two passwords are inconsistent"
                    }
                }
            }
        },
        methods:{
            changeLang(language){
                this.language = language;
            },
            regSave(){
                console.log("regSave");
                if(this.userpass!=this.userpass2){
                    alert(this.uIObj[this.language].errMsgPass);
                }
            }
        }  
    });

    // 安装一个插件
    app.use(myvant);

    app.mount("#app");


</script>